﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Ruleweaver
{
	[TestFixture]
	public class RelativityFixture
	{
		#region IsLessThan

		[Test]
		public void IsLessThanFailsOnNull()
		{
			Assert.IsFalse(Check.That(null as string).IsLessThan("a"));
		}

		[Test]
		public void ZeroIsLessThanOnePasses()
		{
			Assert.IsTrue(Check.That(0).IsLessThan(1));
		}

		[Test]
		public void OneIsLessThanZeroFails()
		{
			Assert.IsFalse(Check.That(1).IsLessThan(0));
		}

		[Test]
		public void OneIsLessThanOneFails()
		{
			Assert.IsFalse(Check.That(1).IsLessThan(1));
		}
		#endregion

		#region IsLessThanOrEqualTo

		[Test]
		public void IsLessThanOrEqualToFailsOnNull()
		{
			Assert.IsFalse(Check.That(null as string).IsLessThanOrEqualTo("a"));
		}

		[Test]
		public void ZeroIsLessThanOrEqualToOnePasses()
		{
			Assert.IsTrue(Check.That(0).IsLessThanOrEqualTo(1));
		}

		[Test]
		public void OneIsLessThanOrEqualToZeroFails()
		{
			Assert.IsFalse(Check.That(1).IsLessThanOrEqualTo(0));
		}

		[Test]
		public void OneIsLessThanOrEqualToOnePasses()
		{
			Assert.IsTrue(Check.That(1).IsLessThanOrEqualTo(1));
		}
		#endregion

		#region IsEqualTo

		[Test]
		public void ZeroIsEqualToOneFails()
		{
			Assert.IsFalse(Check.That(0).IsEqualTo(1));
		}

		[Test]
		public void OneIsEqualToZeroFails()
		{
			Assert.IsFalse(Check.That(1).IsEqualTo(0));
		}

		[Test]
		public void OneIsEqualToOnePasses()
		{
			Assert.IsTrue(Check.That(1).IsEqualTo(1));
		}
		#endregion

		#region IsGreaterThanOrEqualTo

		[Test]
		public void IsGreaterThanOrEqualToFailsOnNull()
		{
			Assert.IsFalse(Check.That(null as string).IsGreaterThanOrEqualTo("a"));
		}

		[Test]
		public void ZeroIsGreaterThanOrEqualToOneFails()
		{
			Assert.IsFalse(Check.That(0).IsGreaterThanOrEqualTo(1));
		}

		[Test]
		public void OneIsGreaterThanOrEqualToZeroPasses()
		{
			Assert.IsTrue(Check.That(1).IsGreaterThanOrEqualTo(0));
		}

		[Test]
		public void OneIsGreaterThanOrEqualToOnePasses()
		{
			Assert.IsTrue(Check.That(1).IsGreaterThanOrEqualTo(1));
		}
		#endregion

		#region IsGreaterThan

		[Test]
		public void IsGreaterThanFailsOnNull()
		{
			Assert.IsFalse(Check.That(null as string).IsGreaterThan("a"));
		}

		[Test]
		public void ZeroIsGreaterThanOneFails()
		{
			Assert.IsFalse(Check.That(0).IsGreaterThan(1));
		}

		[Test]
		public void OneIsGreaterThanZeroPasses()
		{
			Assert.IsTrue(Check.That(1).IsGreaterThan(0));
		}

		[Test]
		public void OneIsGreaterThanOneFails()
		{
			Assert.IsFalse(Check.That(1).IsGreaterThan(1));
		}
		#endregion

		#region IsBetween

		[Test]
		[ExpectedException]
		public void IsBetweenThrowsOnMinimumGreaterThanMaximum()
		{
			Assert.IsTrue(Check.That(1).IsBetween(2, 0));
		}

		[Test]
		public void NullIsBetweenNullAndNull()
		{
			Assert.IsTrue(Check.That(null as string).IsBetween(null, null));
		}

		[Test]
		public void NullIsNotBetweenNullAndNullWithExclusiveBoundary()
		{
			Assert.IsFalse(Check.That(null as string).IsBetween(null, null, BoundaryType.Exclusive));
		}

		[Test]
		[ExpectedException]
		public void IsBetweenThrowsOnUnknownBoundaryAndNullData()
		{
			Check.That(null as string).IsBetween(null, null, (BoundaryType) (-1));
		}

		[Test]
		[ExpectedException]
		public void IsBetweenThrowsOnUnknownBoundaryAndNotNullData()
		{
			Check.That("").IsBetween(null, null, (BoundaryType) (-1));
		}

		[Test]
		public void OneIsBetweenZeroAndTwo()
		{
			Assert.IsTrue(Check.That(1).IsBetween(0, 2));
		}

		[Test]
		public void OneIsNotBetweenTwoAndFour()
		{
			Assert.IsFalse(Check.That(1).IsBetween(2, 4));
		}

		[Test]
		public void IsBetweenDefaultsToInclusiveBoundary()
		{
			Assert.IsTrue(Check.That(1).IsBetween(1, 3) && Check.That(3).IsBetween(1, 3));
		}

		[Test]
		public void InclusiveBoundaryIncludesMinimum()
		{
			Assert.IsTrue(Check.That(1).IsBetween(1, 3, BoundaryType.Inclusive));
		}

		[Test]
		public void InclusiveBoundaryIncludesMaximum()
		{
			Assert.IsTrue(Check.That(3).IsBetween(1, 3, BoundaryType.Inclusive));
		}

		[Test]
		public void ExcludeMinimumBoundaryExcludesMinimum()
		{
			Assert.IsFalse(Check.That(1).IsBetween(1, 3, BoundaryType.ExcludeMinimum));
		}

		[Test]
		public void ExcludeMinimumBoundaryIncludesMaximum()
		{
			Assert.IsTrue(Check.That(3).IsBetween(1, 3, BoundaryType.ExcludeMinimum));
		}

		[Test]
		public void ExcludeMaximumBoundaryIncludesMinimum()
		{
			Assert.IsTrue(Check.That(1).IsBetween(1, 3, BoundaryType.ExcludeMaximum));
		}

		[Test]
		public void ExcludeMaximumBoundaryExcludesMaximum()
		{
			Assert.IsFalse(Check.That(3).IsBetween(1, 3, BoundaryType.ExcludeMaximum));
		}

		[Test]
		public void ExclusiveBoundaryExcludesMinimum()
		{
			Assert.IsFalse(Check.That(1).IsBetween(1, 3, BoundaryType.Exclusive));
		}

		[Test]
		public void ExclusiveBoundaryExcludesMaximum()
		{
			Assert.IsFalse(Check.That(3).IsBetween(1, 3, BoundaryType.Exclusive));
		}
		#endregion
	}
}